from processing.shape.color import dark, color, light, pastel
from processing.model.component import Component
from processing.shape.dynamic_shape import DynamicShape
from processing.shape.static_shape import StaticShape
from processing.shape.drawers import CircleDrawer
from processing.model.conection import Conection
from abc import abstractmethod

class AccessPoint(Component):
    
    def __init__(self):
        Component.__init__(self)
        self.running_time = 0
        self.running_max_time = 5
  
    @abstractmethod
    def on_added(self):
        pass
  
    def update(self):
        self.render.update()
        if(self.render == self.running):
            if(self.running_time > self.running_max_time):
                self.render  = self.stoped
                self.running_time = 0
            else:
                self.running_time += 1
                
    def draw(self):
        self.render.draw()
        
    def send(self, other, color):
        self.add(Conection(self, other, color))
        self.run()
        other.run()
        
    def run(self):
        self.render = self.running
        
  
class EnterPoint(AccessPoint):
    
    def __init__(self):
        AccessPoint.__init__(self)
  
    def on_added(self):
        self.running = DynamicShape(self, CircleDrawer, [12, 6, 3], [light.blue, color.blue, pastel.blue])
        self.stoped  = StaticShape(self, CircleDrawer,  [12, 8],    [light.blue, color.blue])
        self.render  = self.stoped
        
class ExitPoint(AccessPoint):

    def __init__(self):
        AccessPoint.__init__(self)

    def on_added(self):
        self.running = DynamicShape(self, CircleDrawer, [12, 6, 3], [color.orange, color.red, color.yellow])
        self.stoped  = StaticShape(self, CircleDrawer,  [12, 8],    [color.orange, color.red])
        self.render  = self.stoped

